<?php

namespace app\admin\model\help;

use think\Model;

use traits\model\SoftDelete;

class Main extends Model
{

    

    use SoftDelete;

    // 表名
    protected $name = 'help_main';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'createtime_text',
    ];



    public function getCreatetimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function tags()
    {
        return $this->belongsTo('app\admin\model\xlzxinfo\Tags', 'tags', 'id', [], 'LEFT')->setEagerlyType(0);
    }



}
